#!/bin/sh
# lean, mean and very bad R Studio Server installer - Alf 20120925
# should do this with Chef

echo "Rinstall is running" >> /tmp/rinstall

# add EPEL repository to CentOS
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm

# install required packages
yum -q -y install R compat-libgfortran-41 openssl098e-0.9.8e make unzip

# turn off iptables now and at reboot
service iptables stop
chkconfig iptables off

# get and install RStudio Server package
wget -nd http://download2.rstudio.org/rstudio-server-0.96.331-x86_64.rpm
rpm -Uvh rstudio-server-0.96.331-x86_64.rpm

# setup RStudio on port 80
echo www-port=80 > /etc/rstudio/rserver.conf

# restart RStudio server and make start on reboot
service rstudio-server restart
chkconfig rstudio-server on

# create 'research' user account
/usr/sbin/useradd remko
echo "remko" | passwd remko.r --stdin

# unzip R Data bundle into researchers home folder
cd /home/remko
unzip -u /tmp/remko.zip
